Skip to content

feat(tui): internationalize welcome, status/usage panels, dialogs and slash commands#869

Open
meymchen wants to merge 10 commits into
MoonshotAI:mainfrom
meymchen:feat/i18n-walking-skeleton
Open

feat(tui): internationalize welcome, status/usage panels, dialogs and slash commands#869
meymchen wants to merge 10 commits into
MoonshotAI:mainfrom
meymchen:feat/i18n-walking-skeleton

Conversation

@meymchen

Copy link
Copy Markdown

Related Issue

Resolve #868

Problem

Kimi Code TUI already supports language switching via /language, but a large portion of user-facing text (welcome screen, status/usage panels, shared dialogs, slash command descriptions, and the /help panel) is still hard-coded in English. This breaks the experience for zh-CN users and leaves no clear pattern for adding more languages later.

What changed

This PR lands a walking skeleton for TUI internationalization:

  • Introduces new i18n namespaces:
    • cli: CLI-facing notices rendered before the TUI mounts.
    • common: shared dialog vocabulary and keyboard hints.
    • components: expanded keys for welcome, usage, status, and shared dialog labels.
  • Migrates hard-coded strings in the following areas to the active locale:
    • Welcome / onboarding screen
    • Shared dialog labels (choice-picker, model-selector, session-picker, undo-selector, etc.)
    • Slash command descriptions and the /help panel
    • Status panel and usage panel
    • Chrome / footer labels
  • Ensures the localized slash menu refreshes after a language switch.
  • Routes the tui.toml config-parse notice through i18n.
  • Adds/updates tests for the migrated components and language switch behavior.
  • Includes the corresponding changeset and changelog sync.

The approach keeps each locale file a flat MessageTree and groups keys by UI area, which matches the existing commands and reverse-rpc namespaces. This should make it straightforward to add more languages or migrate additional components incrementally.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

meymchen and others added 10 commits June 17, 2026 02:46
Introduce a zero-dependency I18n singleton (lookup, en fallback,
param interpolation, runtime setLocale) modeled on the theme
singleton, with per-module language packs under locales/en and
locales/zh-CN. Add a language setting to tui.toml (auto | en |
zh-CN), resolve auto from the system locale at startup, and
migrate the footer status labels to translated strings.
Build the interactive language-switching path on top of the i18n
skeleton (#1). A LanguageSelectorComponent (ChoicePicker subclass)
offers Auto / English / 简体中文; /settings routes a new "Language"
entry to it. Selecting a language persists to tui.toml, updates app
state, flips the live i18n locale, and repaints so the UI switches
language immediately without a restart. /reload re-reads the language
and re-applies it via setAppState + i18n.setLocale alongside theme.

Closes #2

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Migrate the user-visible English strings in the reverse-RPC approval and
question panels to the i18n layer, with en + zh-CN translations under a new
`reverseRpc` namespace.

- Approval panel headers, choice buttons, danger labels, cwd/scope/more-lines
  metadata, and key hints now resolve via `i18n.t('reverseRpc.approval.*')`.
- Choice/danger labels are localized in the approval adapter at adapt time;
  `selected_label` stays a stable English identifier for the upstream contract.
- Question dialog heading, review/submit prompts, Other/Not-answered labels,
  submit actions, and hints resolve via `i18n.t('reverseRpc.question.*')`.
- Approval preview title and footer hints resolve via
  `i18n.t('reverseRpc.preview.*')`.
- Strings stay colored via `currentTheme`; no chalk named colors, and no
  coloring / printableChar() / keyboard behavior changes.

Locale-render tests assert the panels render in Simplified Chinese under
`zh-CN` and English under `en`.

Resolves #3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Migrate builtin slash-command descriptions, the /help panel chrome
(title, dismiss hint, greeting, section headers, keyboard-shortcut
descriptions, scroll tail), and goal/swarm argument-completion
descriptions to the i18n layer, with en + zh-CN translations under a
new `commands` namespace.

Command names, aliases, and subcommand values stay untranslated —
only human-readable descriptions follow the active locale. Skill
command descriptions remain owned by the skill; only framework
builtins are localized via `localizedBuiltinSlashCommands()`.

Closes #4

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…keleton

# Conflicts:
#	apps/kimi-code/package.json
Migrate the `/usage` and `/status` panel labels to the i18n layer with
`en` + `zh-CN` translations, extending the `components` namespace with
`usage` and `status`.

- usage-panel: session/context/plan section labels, input/output/total
  words, "% used", and empty-state strings now come from
  `i18n.t('components.usage.*')`.
- status-panel: field labels (Model, Directory, Permissions, Plan mode,
  Session, Title, Warning) and rendered values (on/off, not set, none,
  thinking) come from `i18n.t('components.status.*')`.
- Panel chrome titles (' Usage ' / ' Status ') are localized; model names
  and permission-mode identifiers stay untranslated.
- Add a `padEndToWidth` helper so the aligned label columns pad by display
  width, keeping the panels aligned under double-width Chinese characters.

Locale-render assertions verify both panels render Chinese under `zh-CN`
and English under `en`, plus alignment/width under `zh-CN`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Migrate the welcome panel to the i18n layer (title, login/help hints,
unset-model notice, and the Directory/Session/Model/Version/MCP info
labels), padding the label column by display width so it stays aligned
under double-width Chinese.

Introduce a `common` namespace for short phrases shared across
components: the generic Submit/Cancel/Back controls plus the
navigate/select/cancel/clear-search key hints. Migrate the list-style
dialogs (model, choice, session, undo, experiments selectors) and the
plugin-remove Cancel button to `common.*` so each shared phrase is
translated once, with en + zh-CN translations.

Resolve #6

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Render the `tui.toml` parse-failure notice (INVALID_TUI_CONFIG_MESSAGE)
in the active locale. Config load runs before the language is known, so
run-shell now records only that parsing failed and translates the notice
after `i18n.setLocale(...)` resolves the locale — deferred init that
falls back to the default `en` pack before config load.

The `TuiConfigParseError.message` stays English so logs and issue triage
remain English; only the user-facing startup notice is localized.

Adds a `cli` i18n namespace (`cli.config.invalidTuiConfig`) for en and
zh-CN. Closes #7.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fc281a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@meymchen meymchen marked this pull request as draft June 17, 2026 18:03
@meymchen meymchen marked this pull request as ready for review June 17, 2026 18:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc281a7042

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +216 to 218
private readonly title: string = i18n.t('components.usage.panelTitle'),
) {
this.lines = buildLines();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Rebuild cached usage panels on locale changes

When a user has an existing /usage or /status panel in the transcript and then switches language via /settings (or reloads tui.toml), this component keeps both the localized title and the prebuilt lines from construction time. The language-switch paths only request a render, so these visible panels continue showing the old locale; even a later invalidate can rebuild the body but not this stored title. Consider deriving the title/body from builders on render/invalidate or invalidating and recreating these panels when the locale changes.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] TUI 国际化 Walking Skeleton:欢迎页、状态/用量面板、对话框与 Slash 命令英/中文化

1 participant